/*
class complex, the concept of complex numbers.
class complex {
        double re, im;
public:
        complex(double r=0, double i=0) : re(r), im(i) {  }
        complex(const complex& a):re(a.re),im(a.im) {  }
        operator double() const {return re;}        
        complex& operator+= (complex a);
        complex operator+ (complex a);  
        friend ostream& operator<<(ostream& oo, const complex &a); 
};

With the following definitions, describes the type of each expression，write out their values.
    int i=5;    
    double  d=0;
    complex cxa(1.3, -2), cxb=2.5, cxc={1,-1};  
 
(1)  10 + i
(2)   d + i
(3)   d + cxa
(4)   10 + cxc
(5)   i + d + cxb
(6)   cxb = cxa + i
(7)   cxa += cxb + cxc
(8)  complex cxd = cxb;
*/
#include <iostream>
using namespace std;

class complex {
        double re, im;
public:
    complex(double r=0, double i=0) : re(r), im(i) {  } //构造函数
    complex(const complex& a):re(a.re),im(a.im) {  }    //拷贝构造
    operator double() const {return re;}                //默认转换为double
    complex& operator+= (complex a){
        re+=a.re;
        im+=a.im;
        return *this;
    }                    //复数加运算
    complex operator+ (complex a){
        return complex(re+a.re,im+a.im);
    }                      //。。。
    friend ostream& operator<<(ostream& oo, const complex &a); //输出
};

ostream& operator<<(ostream& oo, const complex &a){
    double re = a.re;
    double im = a.im;
    if(re==0&&im==0){
        oo<<0<<endl;
        return oo;
    }
    if(re==0){
        oo<<im<<"i"<<endl;
        return oo;
    }
    if(im==0){
        oo<<re<<endl;
        return oo;
    }
    oo<<re<<im<<"i"<<endl;
    return oo;
}

int main(int argc, char const *argv[])
{
    
    return 0;
}
/*
int i=5;    
double  d=0;
complex cxa(1.3, -2), cxb=2.5, cxc={1,-1};  
 
(1)  10 + i         //15     int
(2)   d + i         //5.0   double
(3)   d + cxa       //1.3   double
(4)   10 + cxc      //11.0  double
(5)   i + d + cxb   //7.5   double
(6)   cxb = cxa + i //6.3,0 complex
(7)   cxa += cxb + cxc  //4.8,-3    complex
(8)  complex cxd = cxb; //2.5,0     cpmplex
*/